<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="button" id="btn1" value="发送异步请求_入门"> <br>
<input type="button" id="btn2" value="发送异步请求_详细"> <br>
<input type="button" id="btn3" value="发送异步请求_语法"> <br>
<input type="button" id="btn4" value="发送异步请求_post"> <br>
</body>


</body>

<script src="js/axios-0.18.0.js">

</script>

<script>
    let btn1 = document.getElementById("btn1");
    btn1.onclick= function () {
        let url="MyServlet";
        let param="name=zs&sex=male";
        let t=function (response) {
            console.log(response.data);
        }
        axios.get(url+"?"+param).then(t);
    }
</script>


<script>
    let btn2 = document.getElementById("btn2");
    btn2.onclick=function () {
        let url="MyServlet";
        let param="name=ls&age=19";
        let t=function (response){
            console.log(response.data);
    }
        let c=function (error) {
            console.log(error);

        }
        let f=function () {
            console.log("最终无论如何都会执行");
        }

        axios.get(url+"?"+param).then(t).catch(c).finally(f);

    }
</script>

<script>
    let btn3 = document.getElementById("btn3");
    btn3.onclick=function () {
        let url="MyServlet";
        let param="name=ls&age=19";
        let t=function (response){
            console.log(response.data);
        }
        let c=function (error) {
            console.log(error);

        }
        let f=function () {
            console.log("最终无论如何都会执行");
        }

        axios.get(url+"?"+param).then(response=>{ console.log(response.data);}).catch(error=> console.log(error)).finally(()=> console.log("最终无论如何都会执行"));

    }
</script>
<script>


    let btn4 = document.getElementById("btn4");
    btn4.onclick=function () {
        let url="MyServlet";
        let param="name=zs&age=22";
        axios.get(url+"?"+param).then(response=>{
            console.log(response.data);}).catch(error=>{
            console.log(error);
        }).finally(()=>{
            "无论如何都得执行的一句话！"
        })
    }









</script>
</html>